package com.qidian.mes.excel;/**
 * ClassName:UserGenderConverterQc
 * Package:com.qidian.mes.excel
 **/

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @Author ppc
 * @Conpany study
 * @Description:
 * @Time 2024/4/12 16:30
 *
 **/
public class UserGenderConverterQc implements Converter<Integer> {
    @Override
    public Integer convertToJavaData(ReadConverterContext<?> context) throws Exception {
        String stringValue = context.getReadCellData().getStringValue();
        return stringValue.equals("正常") ? 1 : stringValue.equals("禁用") ? 2 : 3;
    }

    @Override
    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return new WriteCellData<>(value.equals(1) ? "正常" : value.equals(2) ? "禁用" : "废弃");
    }


}
